package com.dz51.core.basedao.dao;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import com.dz51.core.basedao.query.IConditionBuilder;
import com.dz51.core.page.commond.BasePageCommond;

/**
 * @Title: IConditionSupport.java
 * @Package com.dz51.core.basedao.dao
 * @Description: 条件查询接口
 * @author Zhaoqt
 * @date 2014-5-4 上午6:19:24
 * @version V1.0
 */
public abstract interface IConditionSupport {

	/**
	 * 条件查询db数据. </p> -----------包含sql、hql两种查询语言------------. </p>
	 * -----------paramMap key查询条件匹配符 value查询条件匹配值. </p> ----------- maxResult <
	 * 0 && maxResult < 0 不执行分页查询
	 * 
	 * @Title: executeFind
	 * @param queryStringType
	 * @param sqlOrHql
	 * @param paramMap
	 * @param firstResult
	 * @param maxResult
	 * @return List<?>
	 * @throws Exception
	 */
	public List<?> executeFind(QueryStringType queryStringType, String sqlOrHql, Map<String, Object> paramMap, int firstResult, int maxResult)
			throws Exception;

	/**
	 * count 查询 </p> -----------包含sql、hql两种查询语言------------. </p>
	 * -----------paramMap key查询条件匹配符 value查询条件匹配
	 * 
	 * @Title: count
	 * @param queryStringType
	 * @param sqlOrHql
	 * @param paramMap
	 * @return
	 * @throws ExceptionLong
	 */
	public Long count(QueryStringType queryStringType, String sqlOrHql, Map<String, Object> paramMap) throws Exception;

	/**
	 * {@link com.dz51.core.basedao.query.IConditionBuilder} </p>
	 * 暂实现DetachedCriteria查询.
	 * 
	 * @Title: find
	 * @param conditionBuilder
	 * @return
	 * @throws Exception
	 */
	public BasePageCommond find(IConditionBuilder conditionBuilder) throws Exception;

	/**
	 * @Title: loadEntity
	 * @Description: session.load(..)
	 * @param id
	 * @throws Exception
	 * @return E
	 */
	public abstract Object loadEntity(Serializable id) throws Exception;

	/**
	 * @Title: getEntity
	 * @Description: session.get(..)
	 * @param className
	 * @param id
	 * @throws Exception
	 * @return E
	 */
	public abstract Object getEntity(Serializable id) throws Exception;

	/**
	 * @Title: IConditionSupport.java
	 * @Package com.dz51.core.basedao.dao
	 * @Description: 查询语言类型 SQL/HQL
	 * @author Zhaoqt
	 * @date 2014-5-4 上午6:22:12
	 * @version V1.0
	 */
	public static enum QueryStringType {
		SQL, HQL;
		private QueryStringType() {
		};
	}
}
